package com.example.videoviewdemo;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class MainActivity extends Activity implements OnPreparedListener{
	
	private VideoView mVideo;
	private MediaController mMediaCtrl;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		initVideoView("http://192.168.1.104/yang.mp4");
	}
	
	private void initVideoView(String str){
	
		mMediaCtrl = new MediaController(this);
		
		mVideo = (VideoView) findViewById(R.id.videoView1);
		mVideo.setOnPreparedListener(this);
		mVideo.setVideoURI(Uri.parse(str));
		mVideo.setMediaController(mMediaCtrl);		
	}

	@Override
	public void onPrepared(MediaPlayer mp) {
		// TODO Auto-generated method stub
		
		mVideo.start();
		Toast.makeText(this, "start video...", Toast.LENGTH_SHORT).show();
	}

}
